package com.hghivln.erpwarehouse.business.controller;


import com.hghivln.erpwarehouse.business.entity.Inport;
import com.hghivln.erpwarehouse.business.service.InportService;
import com.hghivln.erpwarehouse.business.vo.InportVo;
import com.hghivln.erpwarehouse.system.common.lang.Result;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  进货
 * </p>
 *
 * @author hghivln
 * @since 2021-07-10
 */
@RestController
@RequestMapping("api/inport")
public class InportController {

    @Autowired
    private InportService inportService;

    @RequestMapping("loadAllInport")
    public Object loadAllInport(InportVo inportVo) {
        return inportService.QueryAllInport(inportVo);
    }

    @RequiresPermissions("inport:add")
    @RequestMapping("addInport")
    public Result addInport(Inport inport) {
        try {
            inportService.addInport(inport);
            return Result.ADD_SUCCESS;
        } catch (Exception e) {
            e.printStackTrace();
            return Result.ADD_ERROR;
        }
    }

    @RequiresPermissions("inport:update")
    @RequestMapping("updateInport")
    public Result updateInport(Inport inport) {
        try {
            inportService.updateById(inport);
            return Result.UPDATE_SUCCESS;
        } catch (Exception e) {
            e.printStackTrace();
            return Result.UPDATE_ERROR;
        }
    }

}
